package com.example.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@RestController
public class FileUploadController {

    private static final Logger logger = LoggerFactory.getLogger(FileUploadController.class);

    @RequestMapping("fileUploadController")
    public Map<String, Object> fileUpload(MultipartFile file) throws IOException {
        String fileName = file.getOriginalFilename();
        logger.info(fileName);

        file.transferTo(new File("D:/" + fileName));
        Map<String, Object> map = new HashMap<>();
        map.put("msg", "ok");
        return map;
    }

}
